
package com.scalar.chiptrack.utils;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Properties;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.scalar.ScalarException;
import com.scalar.chiptrack.commons.SessionKeys;
import com.scalar.chiptrack.commons.Constants;
import com.scalar.chiptrack.commons.dao.ConfigurationDAO;
import com.scalar.chiptrack.users.UserGroup;
import com.scalar.chiptrack.users.notification.NotificationEmailInfo;
import com.scalar.chiptrack.users.notification.dao.NotificationDAO;
import com.scalar.chiptrack.users.dao.UserDAO;


public final class ConfigManager extends HttpServlet {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private static final String SYSTEM_ADMIN_USER_ID = "admin"; // should never change.. sys-ad is always "admin"

    private static String s_currentUserEmail    = null;
    private static Properties s_props           = new Properties();
    private static Properties db_props           = new Properties();
    private static String s_configFile          = null;
    private static String s_documentRoot        = null;
    private static boolean s_initialized        = false;
    private static ServletContext s_servletContext = null;
    private static NotificationEmailInfo   notificationEmailInfo = null;

    // Property keys
    public static final String JOB_RUNNER_JOB_CLEANUP_PERIOD = "scalar.chiptrack.jobRunner.jobCleanupPeriod";
    public static final String JOB_POLLING_PERIOD = "scalar.chiptrack.jobRunner.jobPollingPeriod";
    public static final String JOB_RUNNER_LOG_DIR = "scalar.chiptrack.jobRunner.logDir";
    public static final String SCALAR_SMTP_HOST = "scalar.mailer.smtpHost";
    public static final String SCALAR_ADMIN_EMAIL = "scalar.admin.email";
    public static final String ALARM_MONITOR_REFRESH_INTERVAL = "scalar.alarm.monitor.refreshInterval";
    public static final String DATA_REQUESTOR_CONFIG_FILE = "scalar.datarequestor.configFile";
    public static final String SQL_QUERY_MAPPING_FILE = "scalar.chiptrack.sqlQueryMappingFile";
    public static final String SQL_QUERY_MAPPING_FILE_CMD = "scalar.chiptrack.sqlQueryMappingFile.cmd";
    public static final String LOGGER_DIR = "logger.logDir";
    public static final String LOGGER_DIR_CMD = "logger.logDir.cmd";
    public static final String LOGGER_TARGET = "logger.target";
    public static final String LOGGER_LEVEL = "logger.level";
    public static final String LOGGER_PREFIX = "logger.defaultPrefix";
    public static final String LOGGER_MAX_FILE_SIZE = "logger.maxFileSize";
    public static final String LOGGER_COUNT = "logger.fileCount";
    public static final String DEFAULT_LOGIN_PAGE = "scalar.chiptrack.defaultLoginPage";
    public static final String DEFAULT_INDEX_PAGE = "scalar.chiptrack.defaultIndexPage";
    public static final String DATA_SOURCE_CONFIG_FILE = "scalar.chiptrack.dataSourceConfigFile";
    public static final String DATA_SOURCE_CONFIG_FILE_CMD = "scalar.chiptrack.dataSourceConfigFile.cmd";
    public static final String MSACESS_DATA_SOURCE_CONFIG_FILE = "scalar.chiptrack.msacess.dataSourceConfigFile";
    public static final String MSACESS_DATA_SOURCE_CONFIG_FILE_CMD = "scalar.chiptrack.msacess.dataSourceConfigFile.cmd";
    public static final String TX_DOMAIN_CONFIG_FILE = "scalar.chiptrack.dbTransaction.domainFile";
    public static final String TX_DOMAIN_CONFIG_FILE_CMD = "scalar.chiptrack.dbTransaction.domainFile.cmd";
    public static final String MSACESS_TX_DOMAIN_CONFIG_FILE = "scalar.chiptrack.msacess.dbTransaction.domainFile";
    public static final String MSACESS_TX_DOMAIN_CONFIG_FILE_CMD = "scalar.chiptrack.msacess.dbTransaction.domainFile.cmd";
    public static final String TX_DOMAIN_NAME = "scalar.chiptrack.dbTransaction.domainName";
    public static final String TX_DB_RESOURCE_NAME = "scalar.chiptrack.dbTransaction.resourceName";
    public static final String PROCESS_DOC_FILE_PATH = "scalar.chiptrack.processDocFilePath";
    public static final String PROCESS_DOC_FILE_PATH_CMD = "scalar.chiptrack.processDocFilePath.cmd";
    public static final String CHIPTRAC_CONTEXT = "scalar.chiptrack.context";
    public static final String MESSAGE_DIGEST_SECRET_KEY_FILE = "scalar.chiptract.messageDigestKeyFile";
    public static final String MESSAGE_DIGEST_SECRET_KEY_FILE_CMD = "scalar.chiptract.messageDigestKeyFile.cmd";
    public static final String SCALAR_MAILER_ENABLED = "scalar.mailer.enabled";

    public static final String SCALAR_CHIPTRACK_DAYS_TO_KEEP_ADAPTOR_INFO = "scalar.chiptrack.adaptorDataParser.daysToKeepAdaptorInfo";
    public static final String SCALAR_CHIPTRACK_HOST = "scalar.chiptrack.host";
    public static final String SCALAR_CHIPTRACK_REMIND_PACKINGSLIP_BEFORE = "scalar.chiptrack.jobs.packingSlipReminderDays";
    public static final String SCALAR_CHIPTRACK_SALES_SALES_ORDER_EXPIRES_AFTER_DAYS = "scalar.chiptrack.sales.salesOrderExpiresAfterDays";
    public static final String SCALAR_CHIPTRACK_DOCUMENT_ROOT_DIR = "scalar.chiptrack.documentRootDir";

    public static final String TSMC_ADAPTOR_PCMDATA_DIR = "scalar.chiptrack.adaptor.tsmcAdaptor.pcmdatadirectory";
    public static final String TSMC_ADAPTOR_PCMDATA_DIR_CMD = "scalar.chiptrack.adaptor.tsmcAdaptor.pcmdatadirectory.cmd";
    public static final String TSMC_PCMDATA_PATH_LINK = "scalar.chiptrack.operations.pcmdata.pathlink";

    public static final String SCALAR_CHIPTRACK_ADAPTOR_CONVERTXML2CSV_EXE = "scalar.chiptrack.adatptor.ConvertXML2CVS";
    public static final String SCALAR_CHIPTRACK_ADAPTOR_CONVERTXML2CSV_EXE_CMD = "scalar.chiptrack.adatptor.ConvertXML2CVS.cmd";

    public static final String SCALAR_CHIPTRACK_ADAPTOR_CONVERTXLS2HTML_EXE = "scalar.chiptrack.adatptor.ConvertXLS2HTML";
    public static final String SCALAR_CHIPTRACK_ADAPTOR_CONVERTXLS2HTML_EXE_CMD = "scalar.chiptrack.adatptor.ConvertXLS2HTML.cmd";

    private static final String ADMIN_HOME_PAGE = "scalar.chiptrack.admin.home";
    private static final String IT_HOME_PAGE = "scalar.chiptrack.it.home";
    private static final String ENGINEERING_HOME_PAGE = "scalar.chiptrack.engineering.home";
    private static final String OPERATIONS_HOME_PAGE = "scalar.chiptrack.operations.home";
    private static final String MARKETING_HOME_PAGE = "scalar.chiptrack.marketing.home";
    private static final String FINANCE_HOME_PAGE = "scalar.chiptrack.finance.home";
    private static final String SALES_HOME_PAGE =  "scalar.chiptrack.sales.home";
    private static final String CUSTOMER_HOME_PAGE = "scalar.chiptrack.customer.home";
    private static final String CONFIG_SETUP_HOME = "scalar.chiptrack.config.home";

    private static final String BOARD_KIT_BOARD_BOM_DOC_PATH = "scalar.chiptrack.boardandkit.board.bom.filelocation";
    private static final String BOARD_KIT_BOARD_SCHEMATIC_DOC_PATH = "scalar.chiptrack.boardandkit.board.schematic.filelocation";
    private static final String BOARD_KIT_KIT_BOM_DOC_PATH = "scalar.chiptrack.boardandkit.kit.bom.filelocation";
    private static final String BOARD_KIT_KIT_SCHEMATIC_DOC_PATH = "scalar.chiptrack.boardandkit.kit.schematic.filelocation";
    private static final String PMF_FILE_PATH = "scalar.chiptrack.process.pmf";
    //For RMA in Sales
    private static final String RMA_FILE_PATH = "scalar.chiptrack.sales.rma";
    //For Marketing Forecast
    private static final String FORECAST_DOC_FILE_PATH = "scalar.chiptrack.marketing.forecastDocFilePath";
    // Finance Integration Type...
    private static final String FINANCE_INTEGRATION_TYPE = "scalar.chiptrack.finance.integration.type";

    private static final String VENDOR_MASK_FILE_DIRECTORY = "scalar.chiptrack.vendor.maskfile.directory";

    // Great Plains Datasource file locations...
    public static final String GP_DATA_SOURCE_CONFIG_FILE = "scalar.chiptrack.gpDataSourceConfigFile";
    public static final String GP_DATA_SOURCE_CONFIG_FILE_CMD = "scalar.chiptrack.gpDataSourceConfigFile.cmd";

    // Great Plains DBTransaction DB Resource...
    public static final String GP_TX_DB_RESOURCE_NAME = "scalar.chiptrack.dbTransaction.gpResourceName";

    // Great Plains QueryMappings file locatoin
    public static final String GP_SQL_QUERY_MAPPING_FILE = "scalar.chiptrack.greatPlainsSqlQueryMappingFile";
    public static final String GP_SQL_QUERY_MAPPING_FILE_CMD = "scalar.chiptrack.greatPlainsSqlQueryMappingFile.cmd";
    public static final String GP_COMPANY_NAME = "scalar.chiptrack.greatPlainsCompanyName";
    public static final String GP_COMPANY_ID   = "scalar.chiptrack.gp.companyId";

    // Finance Integration Type...
    private static final String SALES_INTEGRATION_TYPE = "scalar.chiptrack.sales.integration.type";

    // DB Field Values Mapping Fi
    public static final String DB_FIELD_MAPPING_FILE = "scalar.chiptrack.dbFieldMappingFile";

    public static final String ALLOW_VENDOR_TO_UPDATE_SHIPPING_DETAILS = "scalar.chiptrack.operations.packingslip.allowVendorFacing";

    // Site map configuration file location
    public static final String SITE_MAP_CONFIG_FILE = "scalar.chiptrack.siteMapConfigFile";

    private static final String CLIENT_ADDRESSLINE1 = "scalar.chiptrack.client.addressline1";
    private static final String CLIENT_ADDRESSLINE2 = "scalar.chiptrack.client.addressline2";
    private static final String CLIENT_ADDRESSLINE3 = "scalar.chiptrack.client.addressline3";
    private static final String CLIENT_PHONE = "scalar.chiptrack.client.phone";
    private static final String CLIENT_FAX = "scalar.chiptrack.client.fax";

    public static final String INVENTORY_PS_XML2PDF_XSL_FILE = "scalar.chiptrack.dataentry.inventoryps.xml2pdfXslFile";
    public static final String INVENTORY_PS_XML2PDF_XSL_FILE_CMD = "scalar.chiptrack.dataentry.inventoryps.xml2pdfXslFile.cmd";

    public static final String PACKINGSLIP_XML2PDF_XSL_FILE = "scalar.chiptrack.packingSlip.packingSlip.xml2pdfXslFile";
    public static final String PACKINGSLIP_XML2PDF_XSL_FILE_CMD = "scalar.chiptrack.packingSlip.packingSlip.xml2pdfXslFile.cmd";
    public static final String COMMERCIAL_INVOICE_XML2PDF_XSL_FILE = "scalar.chiptrack.packingSlip.commercialInvoice.xml2pdfXslFile";
    public static final String COMMERCIAL_INVOICE_XML2PDF_XSL_FILE_CMD = "scalar.chiptrack.packingSlip.commercialInvoice.xml2pdfXslFile.cmd";
    public static final String PURCHASE_ORDER_XML2PDF_XSL_FILE = "scalar.chiptrack.purchaseorder.xml2pdfXslFile";
    public static final String PURCHASE_ORDER_RECEIPT_ENTRY_XML2PDF_XSL_FILE = "scalar.chiptrack.openPurchaseorderReceiptEntry.xml2pdfXslFile";

    public static final String MAILER_TEMP_DIR  = "scalar.mailer.tempDir";
    public static final String MAILER_TEMP_DIR_CMD  = "scalar.mailer.tempDir.cmd";
    public static final String IMAGES_DIR = "scalar.chiptrack.imagesDir";
    public static final String IMAGES_DIR_CMD = "scalar.chiptrack.imagesDir.cmd";
    public static final String SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE = "scalar.chiptrack.sales.salesOrderAck.xml2pdfXslFile";
    public static final String SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE_CMD = "scalar.chiptrack.sales.salesOrderAck.xml2pdfXslFile.cmd";
    public static final String OPEN_PURCHASE_ORDER_ACKNOWLEDGEMENT_XSL_FILE = "scalar.chiptrack.finance.openPurchaseOrderAck.xml2pdfXslFile";
    public static final String OPEN_PURCHASE_ORDER_ACKNOWLEDGEMENT_XSL_FILE_CMD = "scalar.chiptrack.finance.openPurchaseOrderAck.xml2pdfXslFile.cmd";

    //To generate the pdf acknowledgement for the software sales order.
    public static final String SOFTWARE_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE = "scalar.chiptrack.sales.softwareSalesOrderAck.xml2pdfXslFile";
    public static final String SOFTWARE_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE_CMD = "scalar.chiptrack.sales.softwareSalesOrderAck.xml2pdfXslFile.cmd";

    //In order to store the lecense request xml file
    public static final String LICENSE_REQUEST_DIR = "scalar.chiptrack.license.request.dir";
    public static final String LICENSE_REQUEST_DIR_CMD = "scalar.chiptrack.license.request.dir.cmd";

    //To generate the AIRGO pdf acknowledgement for the software sales order.
    public static final String AIRGO_SOFTWARE_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE = "scalar.chiptrack.sales.airgoSoftwareSalesOrderAck.xml2pdfXslFile";
    public static final String AIRGO_SOFTWARE_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE_CMD = "scalar.chiptrack.sales.airgoSoftwareSalesOrderAck.xml2pdfXslFile.cmd";

    public static final String AIRGO_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE = "scalar.chiptrack.sales.airgoSalesOrderAck.xml2pdfXslFile";
    public static final String AIRGO_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE_CMD = "scalar.chiptrack.sales.airgoSalesOrderAck.xml2pdfXslFile.cmd";

    public static final String PRO_FORMA_INVOICE_XSL_FILE = "scalar.chiptrack.operations.proFormaInvoice.xml2pdfXslFile";
    public static final String PRO_FORMA_INVOICE_XSL_FILE_CMD = "scalar.chiptrack.operations.proFormaInvoice.xml2pdfXslFile.cmd";
    public static final String RMA_ACKNOWLEDGEMENT_XSL_FILE = "scalar.chiptrack.sales.rmaAck.xml2pdfXslFile";
    public static final String RMA_ACKNOWLEDGEMENT_XSL_FILE_CMD = "scalar.chiptrack.sales.rmaAck.xml2pdfXslFile.cmd";
    public static final String QUOTE_ACKNOWLEDGEMENT_XSL_FILE = "scalar.chiptrack.sales.quoteAck.xml2pdfXslFile";
    public static final String QUOTE_ACKNOWLEDGEMENT_XSL_FILE_CMD = "scalar.chiptrack.sales.quoteAck.xml2pdfXslFile.cmd";
    public static final String ASSEMBLY_XSL_FILE = "scalar.chiptrack.operations.assembly.xml2pdfXslFile";
    public static final String ASSEMBLY_XSL_FILE_CMD = "scalar.chiptrack.operations.assembly.xml2pdfXslFile.cmd";
    public static final String IMAGES_SCALARLOGO = "scalar.chiptrack.images.logo";
    public static final String IMAGES_CROSS_CANCEL = "scalar.chiptrack.images.crossCancel";

    public static final String AIRGO_COMMERCIAL_INVOICE_XML2PDF_XSL_FILE = "scalar.chiptrack.packingSlip.commercialInvoice.xml2pdfXslFile";
    public static final String AIRGO_COMMERCIAL_INVOICE_XML2PDF_XSL_FILE_CMD = "scalar.chiptrack.packingSlip.commercialInvoice.xml2pdfXslFile.cmd";

    public static final String AIRGO_QUOTE_ACKNOWLEDGEMENT_XSL_FILE = "scalar.chiptrack.sales.airgoQuoteAck.xml2pdfXslFile";
    public static final String AIRGO_QUOTE_ACKNOWLEDGEMENT_XSL_FILE_CMD = "scalar.chiptrack.sales.airgoQuoteAck.xml2pdfXslFile.cmd";
    public static final String AIRGO_PACKINGSLIP_XML2PDF_XSL_FILE = "scalar.chiptrack.packingSlip.packingSlipAirgo.xml2pdfXslFile";
    public static final String AIRGO_PACKINGSLIP_XML2PDF_XSL_FILE_CMD = "scalar.chiptrack.packingSlip.packingSlipAirgo.xml2pdfXslFile.cmd";

    //WEBLS CONFIGURATION
    public static final String WEBLS_RESPONSE_FILE_DIRECTORY     = "scalar.chiptrack.license.response.dir";
    public static final String WEBLS_RESPONSE_FILE_DIRECTORY_CMD = "scalar.chiptrack.license.response.dir.cmd";

    public static final String ENDCUSTOMER_MIGRATION_FILE_DIRECTORY     = "scalar.chiptrack.sales.endcustomer.dir";
    public static final String ENDCUSTOMER_MIGRATION_FILE_DIRECTORY_CMD = "scalar.chiptrack.sales.endcustomer.dir.cmd";

    public static final String ENDCUSTOMER_MIGRATION_EXCEL_COLUMNS_FILE     = "scalar.chiptrack.sales.endcustomer.excelColumnsFile";
    public static final String ENDCUSTOMER_MIGRATION_EXCEL_COLUMNS_FILE_CMD = "scalar.chiptrack.sales.endcustomer.excelColumnsFile.cmd";

    public static final String PART_NUMBERS_XSL_FILE_CMD = "scalar.chiptrack.sales.partNumbersAck.xml2pdfXslFile.cmd";
    public static final String PART_NUMBERS_XSL_FILE = "scalar.chiptrack.sales.partNumbersAck.xml2pdfXslFile";

    public static final String CLIENT_NAME_AIRGO = "scalar.chiptrack.airgoClient.name";

    public static final String ADAPTOR_LIST = "scalar.chiptrac.adaptorlist";
    public static final String ADAPTOR_LIST_CMD = "scalar.chiptrac.adaptorlist.cmd";
    public static final String ALLOW_ENDUSER_PARTNUMBERS = "scalar.chiptrack.sales.loadEndCustomerPartNumbers";

    public static final String FORECAST_SQL_QUERY_MAPPING_FILE = "scalar.chiptrack.forecast.SqlQueryMappingFile";
    public static final String FORECAST_SQL_QUERY_MAPPING_FILE_CMD = "scalar.chiptrack.forecast.SqlQueryMappingFile.cmd";

    public static final String ASSMRELEASE_XML2PDF_XSL_FILE = "scalar.chiptrack.operations.assmrelease.xml2pdfXslFile";
    public static final String ASSMRELEASE_XML2PDF_XSL_FILE_CMD = "scalar.chiptrack.operations.assmrelease.xml2pdfXslFile.cmd";

    public static final String SORTRELEASE_XML2PDF_XSL_FILE = "scalar.chiptrack.operations.sortrelease.xml2pdfXslFile";
    public static final String SORTRELEASE_XML2PDF_XSL_FILE_CMD = "scalar.chiptrack.operations.sortrelease.xml2pdfXslFile.cmd";

    public static final String FABRELEASE_XML2PDF_XSL_FILE = "scalar.chiptrack.operations.fabrelease.xml2pdfXslFile";
    public static final String FABRELEASE_XML2PDF_XSL_FILE_CMD = "scalar.chiptrack.operations.fabrelease.xml2pdfXslFile.cmd";

    public static final String TESTRELEASE_XML2PDF_XSL_FILE = "scalar.chiptrack.operations.testrelease.xml2pdfXslFile";
    public static final String TESTRELEASE_XML2PDF_XSL_FILE_CMD = "scalar.chiptrack.operations.testrelease.xml2pdfXslFile.cmd";

    public static final String SALES_ORDERS_SHEET_DIRECTORY = "salesOrdersSheet.directory";
    public static final String SALES_ORDERS_SHEET_DIRECTORY_CMD = "salesOrdersSheet.directory.cmd";

    public static final String WIP_FED_SHEET_DIRECTORY = "wipFed.directory";
    public static final String WIP_FED_SHEET_DIRECTORY_CMD = "wipFed.directory.cmd";

    public static final String WIP_FED_SORT_SHEET_DIRECTORY = "wipFed.sort.directory";
    public static final String WIP_FED_SORT_SHEET_DIRECTORY_CMD = "wipFed.sort.directory.cmd";

    public static final String COST_CODE_SHEET_DIRECTORY = "costCodes.directory";
    public static final String COST_CODE_SHEET_DIRECTORY_CMD = "costCodes.directory.cmd";

    public static final String SCALAR_EVENT_LISTENERS_DEF_FILE = "scalar.doctrac.scalarEventListenersDefinitionFile";
    public static final String SCALAR_EVENT_LISTENERS_DEF_FILE_CMD = "scalar.doctrac.scalarEventListenersDefinitionFile.cmd";

    public static final String WIP_FLUSH__FILE_PATH = "scalar.chiptrack.operations.reports.wipFlush.file.path";
    public static final String ON_DEMAND_ADAPTOR_STATUS_TIME_OUT = "scalar.chiptrac.operations.onDemandAdaptor.timeOut";
    public static final String DATA_DUMP_REPORTS_FILE_PATH = "scalar.chiptrack.operations.dataDump.reports.file.path";
    //Inventory Transit Yield Info
    public static final String INVENTORY_TRANSIT_ASSY_YIELD = "scalar.chiptrac.operations.inventoryTransit.assyYield";
    public static final String INVENTORY_TRANSIT_TEST_YIELD = "scalar.chiptrac.operations.inventoryTransit.testYield";
    public static final String INVENTORY_TRANSIT_CS_YIELD   = "scalar.chiptrac.operations.inventoryTransit.classStoreYield";

    public static final String WIPFLUSH_XML2PDF_XSL_FILE = "scalar.chiptrack.operations.wipflush.xml2pdfXslFile";
    public static final String WIPFLUSH_XML2PDF_XSL_FILE_CMD = "scalar.chiptrack.operations.wipflush.xml2pdfXslFile.cmd";

    public static final String SHIPREQUEST_XML2PDF_XSL_FILE = "scalar.chiptrack.operations.shiprequest.xml2pdfXslFile";
    public static final String SHIPREQUEST_XML2PDF_XSL_FILE_CMD = "scalar.chiptrack.operations.shiprequest.xml2pdfXslFile.cmd";

    public static final String GENERATE_PS_SCHEDULED_UPTO_DAYS = "scalar.chiptrac.packingSlip.generatePSScheduledUptoDays";
    public static final String SHOW_FAB_LOT_NUMBER_IN_PACKING_SLIP="scalar.chiptrac.packingslip.loadFabLotNumberForPackingSlip";
    public static final String SHOW_PACKAGE_DIMENSION_IN_PACKING_SLIP="scalar.chiptrac.packingslip.loadPackageDimensionForPackingSlip";
    public static final String PS_SHIPPED_IN_DAYS = "scalar.chiptrac.packingSlip.getPSShippedInDays";
    public static final String PACKING_SLIP_FROM_MAIL_ID = "scalar.chiptrac.packingSlip.fromMailId";
    public static final String SALES_ORDER_FROM_MAIL_ID = "scalar.chiptrac.salesorder.fromMailId";
    public static final String FROM_EMAIL_CATEGORY = "scalar.chiptrac.fromEmail.category";

    public static final String CREDIT_NOTE_ACKNOWLEDGEMENT_XSL_FILE_CMD="scalar.chiptrack.finance.creditNote.xml2pdfXslFile.cmd";
    public static final String CREDIT_NOTE_ACKNOWLEDGEMENT_XSL_FILE="scalar.chiptrack.finance.creditNote.xml2pdfXslFile";

    public static final String SPEC_FILE_SETUP_PATH = "scalar.chiptrack.specificationFileSetup.specFilePath";
	public static final String SPEC_FILE_SETUP_PATH_CMD = "scalar.chiptrack.specificationFileSetup.specFilePath.cmd";

    public static final String COST_CODE_PORTING_FILE_PATH  = "scalar.chiptrack.finance.costCodeFilePath";
    public static final String COST_CODE_PORTING_FILE_PATH_CMD  = "scalar.chiptrack.finance.costCodeFilePath.cmd";
    public static final String QUOTE_SHOW_MIN_ORDER_QTY = "scalar.chiptrack.quote.show.minOrderQty";
    public static final String QUOTE_SHOW_REQUESTED_PRICE = "scalar.chiptrack.quote.show.reqPrice";
    public static final String QUOTE_SHOW_CUST_RESALE_PRICE = "scalar.chiptrack.quote.show.custResalePrice";
    public static final String QUOTE_SHOW_SUGG_RESALE_PRICE = "scalar.chiptrack.quote.show.suggResalePrice";
    private static final String IS_END_CUSTOMER_MANDATORY = "scalar.chiptrack.sales.isEndCustomer.mandatory";
    private static final String IS_END_USER_MANDATORY = "scalar.chiptrack.sales.isEndUser.mandatory";
    private static final String SAMPLES_IS_DEFAULT_ZERO_PRICE = "scalar.chiptrack.sales.samples.isDefaultZeroPrice";
    private static final String IS_QUOTE_TYPE_MANDATORY = "scalar.chiptrack.sales.isQuoteType.mandatory";
    private static final String IS_SHOW_TERMS_LABEL = "scalar.chiptrac.sales.show.terms.label";
    private static final String SEND_PS_SHIPMENT_NOTIFICATION_MAIL = "scalar.chiptrac.packingSlip.sendShipmentNotificationMail";
    private static final String SEND_PS_SHIPMENT_NOTIFICATION_WHEN_PULLED_FROM_CONSIGNMENT_WAREHOUSE = "scalar.chiptrac.packingSlip.sendShipmentNotification.whenPulledFromConsignmentWarehouse";
    private static final String IS_SHOW_TERMSFROMDB_LABEL = "scalar.chiptrac.sales.show.termsfromdb.label";
    private static final String SEND_APPROVED_SO_NOTIFICATION_MAIL_TO_CUSTOMER = "scalar.chiptrac.sales.sendApprovedSalesOrderNotificationMailToCustomer";
    private static final String SEND_APPROVED_QUOTATION_NOTIFICATION_MAIL_TO_CUSTOMER = "scalar.chiptrac.sales.sendApprovedQuotationNotificationMailToCustomer";
    private static final String PRICE_SETUP_PORTING_FILE_PATH = "scalar.chiptrack.marketing.priceSetupFilePath";
    private static final String PRICE_SETUP_PORTING_FILE_PATH_CMD = "scalar.chiptrack.marketing.priceSetupFilePath.cmd";
    private static final String PACKINGSLIP_UOM_VALUE = "scalar.chiptrac.packingslip.uom";
    private static final String PACKINGSLIP_SHIPDATE_ALLOWED_ELAPSED_DAYS = "scalar.chiptrac.packingslip.shipdate.allowed.elapsedDays";
    private static final String PACKINGSLIP_IS_INCLUDE_CI = "scalar.chiptrac.packingslip.is.include.commercialInvoice";
    private static final String JOB_ABORT_TIME_MILLIS = "scalar.chiptrack.jobRunner.jobAbortTimeMillis";
    private static final String SALES_LOAD_END_CUSTOMERS_FOR_NEW="scalar.chiptrac.sales.loadEndCustomersForNew";
    private static final String SALES_LOAD_END_USERS_FOR_NEW="scalar.chiptrac.sales.loadEndUsersForNew";
    private static final String SALES_LOAD_QUOTATION_QUESTIONNAIRE="scalar.chiptrac.sales.loadQuotationQuestionnaire";
    public static final String CUMMULATIVE_YIELD_REPORT_FILE_DIR        = "scalar.chiptrack.engineering.cummulativeYieldReportFileDir";
    public static final String CUMMULATIVE_YIELD_REPORT_FILE_DIR_CMD    = "scalar.chiptrack.engineering.cummulativeYieldReportFileDir.cmd";

    public static final String QUESTIONNAIRE_FILE_SETUP_PATH = "scalar.chiptrack.quote.questionnaireFilePath";
    public static final String QUESTIONNAIRE_FILE_SETUP_PATH_CMD = "scalar.chiptrack.quote.questionnaireFilePath.cmd";
    public static final String QUOTATION_SEND_INTERNAL_COMMENTS_MAIL = "scalar.chiptrac.sales.sendInternalCommentsMail";
    public static final String IMAGES_CROSS_NOTAPPROVED = "scalar.chiptrack.images.crossNotApproved";
    public static final String NO_OF_DECIMALSIN_AMOUNT_FORMAT ="scalar.chiptrac.sales.noOfDecimalsinAmountFormat";

    public static final String EXPIRY_NO_OF_DAYS_FROM_CURRENT_DATE = "scalar.chiptrack.user.expiryUsers.NoOfDaysFromCurrentDate";
    public static final String EXPIRY_USERS_REPORT_FILE_PATH        = "scalar.chiptrack.user.expiryUsersReport";
    public static final String EXPIRY_USERS_REPORT_FILE_PATH_CMD    = "scalar.chiptrack.user.expiryUsersReport.cmd";
    public static final String IS_DUPLICATE_MKTG_PART_NUMBERS_ALLOWED    = "scalar.chiptrack.isDuplicateMktgPartNumbersAllowed";
    public static final String SALES_PORTING_FILE_DIR_CMD = "scalar.chiptrack.sales.salesPortingFileDir.cmd";
    public static final String SALES_PORTING_FILE_DIR = "scalar.chiptrack.sales.salesPortingFileDir";
    public static final String RELEASE_FILE_DIR = "scalar.chiptrack.operations.releaseFileDir";
    public static final String RELEASE_FILE_DIR_CMD = "scalar.chiptrack.operations.releaseFileDir.cmd";
    public static final String RELEASE_WAFERMAP_FILE_DIR = "scalar.chiptrack.operations.release.waferMapFileDir";
    public static final String RELEASE_WAFERMAP_FILE_DIR_CMD = "scalar.chiptrack.operations.release.waferMapFileDir.cmd";

    public static final String FORECAST_PORTING_FILE_DIR_CMD = "scalar.chiptrack.forecast.salesforecastPortingFileDir.cmd";
    public static final String FORECAST_PORTING_FILE_DIR = "scalar.chiptrack.forecast.salesforecastPortingFileDir";
    public static final String PO_PORTING_FILE_DIR_CMD = "scalar.chiptrack.po.poPortingFileDir.cmd";
    public static final String PO_PORTING_FILE_DIR = "scalar.chiptrack.po.poPortingFileDir";
    public static final String FAB_PORTING_FILE_DIR_CMD = "scalar.chiptrack.fab.fabPortingFileDir.cmd";
    public static final String FAB_PORTING_FILE_DIR = "scalar.chiptrack.fab.fabPortingFileDir";
    public static final String PRODUCT_PORTING_FILE_DIR ="scalar.chiptrack.product.productPortingFileDir";
    public static final String FAB_INVOICE_PORTING_FILE_DIR ="scalar.chiptrack.fab.invoicePortingFileDir";
    public static final String CUSTOMER_PORTING_FILE_DIR ="scalar.chiptrack.customer.customerPortingFileDir";

    public static final String BUILD_FORECAST_PORTING_FILE_DIR_CMD = "scalar.chiptrack.forecast.buildforecastPortingFileDir.cmd";
    public static final String BUILD_FORECAST_PORTING_FILE_DIR = "scalar.chiptrack.forecast.buildforecastPortingFileDir";

    public static final String RELEASE_SHOW_MARKING_LINES="scalar.chiptrack.operations.release.showMarkingLines";
    public static final String GENERATE_ASSY_RELEASE_NUMBER="scalar.chiptrack.operations.release.isGenerateLotNumber";
    public static final String IS_BOM_INVENOTORY_PULLING_BY_WAFER_ID="scalar.chiptrack.operations.release.isBomPullingByWaferId";
    public static final String IS_SHOW_RELEASE_SHIPLOT_GROUP_BY_WAFER_ID="scalar.chiptrack.operations.release.isShowReleaseShipLotGroupByWaferId";
    public static final String SHOW_RELEASE_DIEBANKLOT_NO_LABEL="scalar.chiptrack.release.assm.showDieBankLotNo";
    public static final String SHOW_RELEASE_SCREENPRINT_ORDER_LABEL="scalar.chiptrack.release.assm.showScreenPrintOrder";
    public static final String SHOW_RELEASE_BACKGRIND_ORDER_LABEL="scalar.chiptrack.release.assm.showBackGrindOrder";
    public static final String GENERATE_TEST_RELEASE="scalar.chiptrack.release.assm.generateTestRelease";
    public static final String DEFAULT_TEST_RELEASE_FILE_FORMAT="scalar.chiptrack.release.test.defaultfileformat";
    public static final String DEFAULT_ASSM_RELEASE_FILE_FORMAT="scalar.chiptrack.release.assm.defaultfileformat";

    public static final String IS_SAVE_END_CUSTOMER_END_USER="scalar.chiptrack.sales.salesorder.isSaveEndCostomerandEndUser";
    public static final String IS_CALCULATE_COST_BY_CUMMULATIVE="scalar.chiptrack.finance.cost.isCalculateCostByCummulative";

    public static final String SHOW_UPDATE_VIEW_COST_BY_LOCATION="scalar.chiptrack.finance.cost.showLocation";
    public static final String CUSTOMER_ALLOW_MULTIPLE_BILLING_ADDRESSES="scalar.chiptrack.customer.allowMultipleBillingAddresses";
    public static final String BARCODE_CONFIG_FILE="scalar.chiptrack.barcode.config.file";
	public static final String ADDRESS_CITY_MAX_LENGTH = "scalar.chiptrack.address.city.max.length";
	public static final String ADDRESS_STATE_MAX_LENGTH = "scalar.chiptrack.address.state.max.length";
	public static final String ADDRESS_ZIP_MAX_LENGTH = "scalar.chiptrack.address.zip.max.length";
	public static final String ADDRESS_PHONE_MAX_LENGTH = "scalar.chiptrack.address.phone.max.length";
	public static final String ADDRESS_FAX_MAX_LENGTH = "scalar.chiptrack.address.fax.max.length";
	public static final String ADDRESS_TAGNAME_MAX_LENGTH = "scalar.chiptrack.address.tagname.max.length";
	public static final String SALESPERSON_NAME_MAX_LENGTH = "scalar.chiptrack.salesperson.name.max.length";
	public static final String REGION_NAME_MAX_LENGTH = "scalar.chiptrack.region.max.length";
	public static final String SHIPPING_METHOD_MAX_LENGTH = "scalar.chiptrack.shippingmethod.max.length";
	public static final String PAYMENT_TERMS_MAX_LENGTH = "scalar.chiptrack.paymentterms.max.length";
	public static final String FORECAST_SHOW_CONFIDENCE_LEVEL = "scalar.chiptrack.forecast.show.confidence.level";
	public static final String FORECAST_SHOW_PRICE = "scalar.chiptrack.forecast.show.price";
    public static final String PROP_SHOW_SALES_LINEITEM_CUSTOM_PRICE_FIELD1="scalar.chiptrack.sales.show.lineitem.customPriceField1";
    public static final String PROP_SHOW_SALES_LINEITEM_CUSTOM_TEXT_FIELD1="scalar.chiptrack.sales.show.lineitem.customTextField1";
    public static final String PROP_SHOW_SALES_LINEITEM_BASE_ORDER_QTY="scalar.chiptrack.sales.show.lineitem.baseOrderQty";
    public static final String PROP_SHOW_END_USER_IN_FORECAST_REPORTS="scalar.chiptrack.show.endUser.in.forecast.reprots";
    public static final String PROP_SHOW_USERTXT1_IN_FORECAST_REPORTS="scalar.chiptrack.show.usertxt1.in.forecast.reprots";
    public static final String SHOW_PROCESS_PARAM_ECCNHTS_CODE_IN_PACKINGSLIP="scalar.chiptrack.operations.packingslip.showECCNHTSCode";
    public static final String PROP_SHOW_SALES_LINEITEM_MARKETING_PART_NUMBER="scalar.chiptrack.sales.show.lineitem.marketingPartNumber";
    public static final String SHOW_MRKT_PARTNO_PACKINGSLIP="scalar.chiptrack.operations.packingslip.showMrktPartNumber";
    public static final String SHOW_MFG_PARTNO_PACKINGSLIP="scalar.chiptrack.operations.packingslip.showMfgPartNumber";
    public static final String SEND_SO_INTERNAL_COMMENTS_MAIL="scalar.chiptrack.sales.sendSOInternalComments";
    public static final String SHOW_PRODUCT_SETUP_FROM_DB="scalar.chiptrack.operations.product.showProductSetUpFromDB";
    public static final String SHOW_SHIPPED_LOT_BY_WAFER_ID="scalar.chiptrack.operations.shippedLot.showShippedLotByWafer";


	static {
        if ((System.getProperty("cmd") != null) && (s_initialized == false)) {
            new ConfigManager().init();
            s_initialized = true;
        }
    }

    public void init() {

        if (s_initialized == true)
        {
            return;
        }


        InputStream in = null;
        try
        {

            if (System.getProperty("cmd") != null)
            {
                s_configFile = System.getProperty ("scalar.properties");    // See if its a system property
                System.out.println ("config file = " + s_configFile);
            }
            else
            {
                s_servletContext = getServletContext();
                s_configFile = s_servletContext.getRealPath ("/config/scalar.properties");

                s_documentRoot = s_servletContext.getRealPath("");
                System.out.println ("document root = " + s_documentRoot);
            }

            in = new FileInputStream (s_configFile);
            s_props.load(in);
            try
            {
                db_props = ConfigurationDAO.getConfigurationProps(null);
                System.out.println("DB Configuration properties loaded successfully");
            }
            catch ( ScalarException e )
            {
                e.printStackTrace();
            }

            try
            {
                 notificationEmailInfo = NotificationDAO.getAllNotificationMailIdList();
                 System.out.println("Notification Emails Loaded");
            }catch(Exception e) { /*System.out.println(" Exception in getinng email info into context");*/ }

            System.out.println ("Scalar.properties file = " + s_configFile);
            s_initialized = true;

        }
        catch (Exception e) {
            System.out.println ("Failed to load Scalar global properties file, specify \"scalar.properties\" System property that points to the scalar properties file");
            e.printStackTrace();
        }
        finally {
            if (in != null) {
                try { in.close(); } catch (IOException ignore){}
            }
        }

        System.out.println ("Configuration Manager has been started");
    }


    public void destroy() {
        System.out.println ("Configuration Manager has been stopped");
    }


    public void service (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String action = request.getParameter ("action");

        LinkedHashMap<String, String> errors = new LinkedHashMap<String, String>();
        LinkedHashMap<String, String> info = new LinkedHashMap<String, String>();

        if ("save".equalsIgnoreCase (action))
        {

            String mailHost                 = request.getParameter ("mailHost");
            String jobCleanupPeriod         = request.getParameter ("jobCleanupPeriod");
            String jobPollingPeriod         = request.getParameter ("jobPollingPeriod");
            String alarmMonitorPeriod       = request.getParameter ("alarmMonitorPeriod");
            String adminEmail               = request.getParameter ("adminEmail");
            String remindPackingSlipsBefore = request.getParameter ("packingSlipReminderDays");
            String packingSlipFromEmail     = request.getParameter ( "packingSlipFromEmail" );
            String salesOrderFromEmail      = request.getParameter ( "salesOrderFromEmail" );
            String fromEmailCategory      = request.getParameter ( "fromEmailCategory" );

            if ((mailHost != null) && (mailHost.trim().length() != 0)) {
                s_props.setProperty (SCALAR_SMTP_HOST, mailHost);

            }
            else {
                errors.put ("Invalid value for Mail Host", null);
            }

            if ((adminEmail != null) && (adminEmail.trim().length() != 0) && (adminEmail.indexOf("@") != -1)) {
                s_props.setProperty (SCALAR_ADMIN_EMAIL, adminEmail);
            }
            else {
                errors.put ("Invalid Email", null);
            }

            try {
                Integer.parseInt (jobCleanupPeriod);
                s_props.setProperty (JOB_RUNNER_JOB_CLEANUP_PERIOD, jobCleanupPeriod);
            }
            catch (NumberFormatException ignore) {
                errors.put ("Invalid Job Cleanup Period", null);
            }

            try {
                Integer.parseInt (jobPollingPeriod);
                s_props.setProperty (JOB_POLLING_PERIOD, jobPollingPeriod);
            }
            catch (NumberFormatException ignore) {
                errors.put ("Invalid Job Polling Period", null);
            }

            try {
                Integer.parseInt (alarmMonitorPeriod);
                s_props.setProperty (ALARM_MONITOR_REFRESH_INTERVAL, alarmMonitorPeriod);
            }
            catch (NumberFormatException ignore) {
                errors.put ("Invalid Alarm Monitor Period", null);
            }

            try {
                Integer.parseInt (remindPackingSlipsBefore);
                s_props.setProperty (SCALAR_CHIPTRACK_REMIND_PACKINGSLIP_BEFORE, remindPackingSlipsBefore);
            }
            catch (NumberFormatException nfe) {
                errors.put ("Invalid value for packing slip reminder property", null);
            }

            s_props.setProperty (FROM_EMAIL_CATEGORY, fromEmailCategory);

            if ((packingSlipFromEmail != null) && (packingSlipFromEmail.trim().length() != 0) && (packingSlipFromEmail.indexOf("@") != -1)) {
                s_props.setProperty (PACKING_SLIP_FROM_MAIL_ID, packingSlipFromEmail);
            }
            else {
                errors.put ("Invalid Packing Slip Email", null);
            }

            if ( ( salesOrderFromEmail != null) && ( salesOrderFromEmail.trim().length() != 0 ) && ( salesOrderFromEmail.indexOf("@") != -1 ) )
            {
                s_props.setProperty ( SALES_ORDER_FROM_MAIL_ID, salesOrderFromEmail );
            }
            else
            {
                errors.put ( "Invalid Sales Order Email", null );
            }

            if (errors.isEmpty() == true) {
                FileOutputStream out = null;
                try {
                    out = new FileOutputStream (s_configFile);
                    s_props.store (out, null /* header */);

                    info.put ("Configuration has been updated successfully", null);
                    request.setAttribute (SessionKeys.INFO_MESSAGES, info);
                }
                catch (IOException ioe) {
                    errors.put ("Internal Server Error", "Could not update Configuration");
                    ioe.printStackTrace();
                }
                finally {
                    if (out != null) {
                        try { out.close(); } catch (IOException ignore) {}
                    }
                }
            }

            if (errors.isEmpty() == false) {
                request.setAttribute (SessionKeys.ERROR_MESSAGES, errors);
            }

        }
        else if ("viewall".equalsIgnoreCase (action)) {
            s_props.list (response.getWriter());
        }

        getServletContext().getRequestDispatcher (s_props.getProperty (CONFIG_SETUP_HOME)).forward(request, response);
    }

    public ConfigManager() {
    }

    public boolean isInitialized() {
        return s_initialized;
    }

    public static String getDocumentRoot() {
        if (s_documentRoot == null) {
            s_documentRoot = s_props.getProperty (SCALAR_CHIPTRACK_DOCUMENT_ROOT_DIR);
        }
        return s_documentRoot;
    }

    public static int getSalesOrderExpiresAfterDays() {
        int expiresAfterDays = 0;

        try {
            expiresAfterDays = Integer.parseInt (s_props.getProperty (SCALAR_CHIPTRACK_SALES_SALES_ORDER_EXPIRES_AFTER_DAYS));
        }
        catch (NumberFormatException nfe) {
            System.out.println ("WARNING!! WARNING!! WARNING!! Property \""+ SCALAR_CHIPTRACK_SALES_SALES_ORDER_EXPIRES_AFTER_DAYS + " is not defined");
        }

        return expiresAfterDays;
    }

    public static String getChipTracHost() {
        return s_props.getProperty (SCALAR_CHIPTRACK_HOST);
    }

    public static int getDaysToKeepAdaptorRunInfo() {

        int daysToKeep = 10;

        try {
            daysToKeep = Integer.parseInt (s_props.getProperty (SCALAR_CHIPTRACK_DAYS_TO_KEEP_ADAPTOR_INFO));
        }
        catch (NumberFormatException nfe) {
        }

        return daysToKeep;
    }

    public static String getJobRunnerLogDir() {
        return s_props.getProperty (JOB_RUNNER_LOG_DIR);
    }

    public static boolean isMailerEnabled() {
        return Boolean.valueOf (s_props.getProperty (SCALAR_MAILER_ENABLED)).booleanValue();
    }

    public static int getPackingSlipReminderDays() {
        int remindBefore = 7;   // default
        try {
            remindBefore = Integer.parseInt (s_props.getProperty (SCALAR_CHIPTRACK_REMIND_PACKINGSLIP_BEFORE));
        }
        catch (NumberFormatException nfe) {
        }

        return remindBefore;
    }

    public static String getMessageDigestSecretKeyFile() {

        if (System.getProperty("cmd") != null) {
            return s_props.getProperty (MESSAGE_DIGEST_SECRET_KEY_FILE_CMD);
        }

        return s_servletContext.getRealPath (s_props.getProperty (MESSAGE_DIGEST_SECRET_KEY_FILE, ""));
    }

    public static String getChipTracContext() {
        return s_props.getProperty (CHIPTRAC_CONTEXT);
    }

    public static String getTxDBResourceName() {
        return s_props.getProperty (TX_DB_RESOURCE_NAME);
    }

    // Balaram,  Oct 23, 2003
    public static String getGreatPlainsTxDBResourceName() {
        return s_props.getProperty (GP_TX_DB_RESOURCE_NAME);
    }

    public static String getTxDomainName() {
        return s_props.getProperty (TX_DOMAIN_NAME);
    }

    public static String getTxDomainCOnfigFile() {

        if (System.getProperty("cmd") != null) {
            return s_props.getProperty (TX_DOMAIN_CONFIG_FILE_CMD);
        }

        return s_servletContext.getRealPath(s_props.getProperty (TX_DOMAIN_CONFIG_FILE, ""));
    }

    public static String getDataSourceConfigFile() {

        if (System.getProperty("cmd") != null) {
            return s_props.getProperty (DATA_SOURCE_CONFIG_FILE_CMD);
        }

        return s_servletContext.getRealPath(s_props.getProperty (DATA_SOURCE_CONFIG_FILE, ""));

    }
    public static String getMsAcessDataSourceConfigFile() {

        if (System.getProperty("cmd") != null) {
            return s_props.getProperty (MSACESS_DATA_SOURCE_CONFIG_FILE_CMD);
        }

        return s_servletContext.getRealPath(s_props.getProperty (MSACESS_DATA_SOURCE_CONFIG_FILE, ""));

    }

    // Balaram, on Oct 23, 2003
    public static String getGreatPlainsDataSourceConfigFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( GP_DATA_SOURCE_CONFIG_FILE_CMD );
        }

        return s_servletContext.getRealPath( s_props.getProperty ( GP_DATA_SOURCE_CONFIG_FILE, "" ) );
    }

    public static String getDefaultLoginPage() {
        return s_props.getProperty (DEFAULT_LOGIN_PAGE);
    }

    public static String getDefaultIndexPage() {
        return s_props.getProperty (DEFAULT_INDEX_PAGE);
    }

    public static int getMaxLogFileSize() {
        int maxFileSize = 1024*4;

        try {
            maxFileSize = Integer.parseInt (s_props.getProperty(LOGGER_MAX_FILE_SIZE));
        }
        catch (NumberFormatException ignore) {
        }

        return maxFileSize;
    }

    public static String getLogLevel() {
        return s_props.getProperty (LOGGER_LEVEL);
    }

    public static String getLogTarget() {
        return s_props.getProperty (LOGGER_TARGET);
    }

    public static String getLogPrefix() {
        return s_props.getProperty (LOGGER_PREFIX, "Scalar");
    }

    public static String getLogDirectory() {
        if (System.getProperty("cmd") != null) {
            return s_props.getProperty(LOGGER_DIR_CMD);
        }

        return s_servletContext.getRealPath( s_props.getProperty(LOGGER_DIR, ""));
    }

    public static int getLoggerCount()
    {
        int logcount = 1;
        try
        {
            s_props.list(System.out);
            return Integer.parseInt ( s_props.getProperty ( LOGGER_COUNT) );
        }
        catch (NumberFormatException ignore)
        {
            ignore.printStackTrace();
        }
        return logcount;
    }

    public static String getSqlQueryMappingFile() {

        if (System.getProperty("cmd") != null) {
            return s_props.getProperty (SQL_QUERY_MAPPING_FILE_CMD);
        }

        return s_servletContext.getRealPath(s_props.getProperty (SQL_QUERY_MAPPING_FILE, ""));
    }

    // Balaram, Oct 23, 2003
    public static String getGreatPlainsSqlQueryMappingFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( GP_SQL_QUERY_MAPPING_FILE_CMD );
        }

        return s_servletContext.getRealPath( s_props.getProperty ( GP_SQL_QUERY_MAPPING_FILE, "" ) );
    }

    // Balaram, Oct 30, 2003
    public static String getDBFieldMappingFile()
    {
        return s_servletContext.getRealPath( s_props.getProperty ( DB_FIELD_MAPPING_FILE, "" ) );
    }


    public static String getMailHost() {
        return s_props.getProperty (SCALAR_SMTP_HOST);
    }

    public static String getSysAdminEmail() {

        String email = null;
        try {
            email = UserDAO.getEmailByUserId (SYSTEM_ADMIN_USER_ID);
        }
        catch (ScalarException se) {
            System.out.println ("Could not system administrator emailID: " + se.getMessage());
            se.printStackTrace();
        }

        return email;
    }

    public static long getAlarmMonitorRefreshInterval() {
        long value = -1;
        try {
            value = Long.parseLong (s_props.getProperty (ALARM_MONITOR_REFRESH_INTERVAL));
        }
        catch (NumberFormatException nfe) {
            // illegal value.. return -1
        }
        return value;
    }

    public static String getDataRequestorConfigFile() {
        return s_props.getProperty(DATA_REQUESTOR_CONFIG_FILE);
    }


    public static long getJobRunnerCleanupPeriod() {
        String period = s_props.getProperty (JOB_RUNNER_JOB_CLEANUP_PERIOD);
        long value = -1;
        try {
            value = Long.parseLong (period);
        }
        catch (NumberFormatException nfe) {
            // invalid property value, return -1
        }

        return value;
    }


    public static long getJobPollingPeriod() {
        String period = s_props.getProperty (JOB_POLLING_PERIOD);
        long value = -1;
        try {
            value = Long.parseLong (period);
        }
        catch (NumberFormatException nfe) {
            // invalid property value, return -1
        }

        return value;
    }


    public static String getITHomePage() {
        return s_props.getProperty (IT_HOME_PAGE);
    }

    public static String getAdminHomePage() {
        return s_props.getProperty (ADMIN_HOME_PAGE);
    }

    public static String getEngineeringHomePage() {
        return s_props.getProperty (ENGINEERING_HOME_PAGE);
    }

    public static String getOperationsHomePage() {
        return s_props.getProperty (OPERATIONS_HOME_PAGE);
    }

    //chakravarthy : get the context path for board and kit documents
    public static String getBoardBomLocationContext() {
        return s_props.getProperty (BOARD_KIT_BOARD_BOM_DOC_PATH);
    }

    public static String getBoardSchematicLocationContext() {
        return s_props.getProperty (BOARD_KIT_BOARD_SCHEMATIC_DOC_PATH);
    }

    public static String getKitBomLocationContext() {
        return s_props.getProperty (BOARD_KIT_KIT_BOM_DOC_PATH);
    }

    public static String getKitSchematicLocationContext() {
        return s_props.getProperty (BOARD_KIT_KIT_SCHEMATIC_DOC_PATH);
    }

    public static String getMarketingHomePage() {
        return s_props.getProperty (MARKETING_HOME_PAGE);
    }

    public static String getFinanceHomePage() {
        return s_props.getProperty (FINANCE_HOME_PAGE);
    }

    public static String getSalesHomePage() {
        return s_props.getProperty (SALES_HOME_PAGE);
    }

    public static String getCustomerHomePage() {
        return s_props.getProperty (CUSTOMER_HOME_PAGE);
    }

    public static String getIndexPageByGroupName (String groupName) {

        if (groupName == null) {
            return getDefaultIndexPage();
        }

        if (groupName.equalsIgnoreCase (UserGroup.USER_GROUP_ADMIN)) {
            return s_props.getProperty (ADMIN_HOME_PAGE);
        }

        if (groupName.equalsIgnoreCase (UserGroup.USER_GROUP_ENGINEERING)) {
            return s_props.getProperty (ENGINEERING_HOME_PAGE);
        }

        if (groupName.equalsIgnoreCase (UserGroup.USER_GROUP_OPERATIONS)) {
            return s_props.getProperty (OPERATIONS_HOME_PAGE);
        }

        if (groupName.equalsIgnoreCase (UserGroup.USER_GROUP_MARKETING)) {
            return s_props.getProperty (MARKETING_HOME_PAGE);
        }

        if (groupName.equalsIgnoreCase (UserGroup.USER_GROUP_FINANCE)) {
            return s_props.getProperty (FINANCE_HOME_PAGE);
        }

        if (groupName.equalsIgnoreCase (UserGroup.USER_GROUP_SALES)) {
            return s_props.getProperty (SALES_HOME_PAGE);
        }

        if (groupName.equalsIgnoreCase (UserGroup.USER_GROUP_CUSTOMER)) {
            return s_props.getProperty (CUSTOMER_HOME_PAGE);
        }

        if (groupName.equalsIgnoreCase (UserGroup.USER_GROUP_IT)) {
            return s_props.getProperty (IT_HOME_PAGE);
        }

        // GROUP NAME NOT FOUND
        return getDefaultIndexPage();
    }

    // Current user Email ID
    public static String getCurrentUserEmail() {
        return s_currentUserEmail;
    }
    public static void setCurrentUserEmail (String email) {
        s_currentUserEmail = email;
    }

    //Process documentation file path
    //Added by Mallikarjun Ankati
    public static String getProcessDocFilePath(){

        if (System.getProperty("cmd") != null) {
            return s_props.getProperty(PROCESS_DOC_FILE_PATH_CMD);
        }

        return s_servletContext.getRealPath(s_props.getProperty(PROCESS_DOC_FILE_PATH, ""));
    }

    public static String getProcessDocWebFilePath(){
        return s_props.getProperty(PROCESS_DOC_FILE_PATH);
    }

    //Added by kumar
    public static String getClientAddressLine1()
    {
        return s_props.getProperty (CLIENT_ADDRESSLINE1);
    }
    public static String getClientAddressLine2()
    {
        return s_props.getProperty (CLIENT_ADDRESSLINE2);
    }
    public static String getClientAddressLine3()
    {
        return s_props.getProperty (CLIENT_ADDRESSLINE3);
    }
    public static String getClientPhone()
    {
        return s_props.getProperty (CLIENT_PHONE);
    }
    public static String getClientFax()
    {
        return s_props.getProperty (CLIENT_FAX);
    }

    public static String getInventoryPSXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( INVENTORY_PS_XML2PDF_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( INVENTORY_PS_XML2PDF_XSL_FILE , "" ) );
    }
    public static String getPackingSlipXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( PACKINGSLIP_XML2PDF_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( PACKINGSLIP_XML2PDF_XSL_FILE , "" ) );
    }

    public static String getCommercialInvoiceXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( COMMERCIAL_INVOICE_XML2PDF_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( COMMERCIAL_INVOICE_XML2PDF_XSL_FILE , "" ) );
    }

    public static String getPurchaseOrderXml2PdfXslFile()
    {
        return s_servletContext.getRealPath( s_props.getProperty ( PURCHASE_ORDER_XML2PDF_XSL_FILE , "" ) );
    }

    public static String getPurchaseOrderReceiptEntryXml2PdfXslFile()
    {
        return s_servletContext.getRealPath( s_props.getProperty ( PURCHASE_ORDER_RECEIPT_ENTRY_XML2PDF_XSL_FILE , "" ) );
    }

    public static String getSalesOrderAckXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE , "" ) );
    }

    public static String getOpenPurchaseOrderAckXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( OPEN_PURCHASE_ORDER_ACKNOWLEDGEMENT_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( OPEN_PURCHASE_ORDER_ACKNOWLEDGEMENT_XSL_FILE , "" ) );
    }

    public static String getSoftwareSalesOrderAckXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( SOFTWARE_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( SOFTWARE_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE , "" ) );
    }

    public static String getAirgoSalesOrderAckXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( AIRGO_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( AIRGO_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE , "" ) );
    }

    public static String getAirgoSoftwareSalesOrderAckXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( AIRGO_SOFTWARE_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( AIRGO_SOFTWARE_SALES_ORDER_ACKNOWLEDGEMENT_XSL_FILE , "" ) );
    }

    public static String getProFormaInvoiceXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( PRO_FORMA_INVOICE_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( PRO_FORMA_INVOICE_XSL_FILE , "" ) );
    }

    public static String getAssemblyXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( ASSEMBLY_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( ASSEMBLY_XSL_FILE , "" ) );
    }

    public static String getRmaAckXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( RMA_ACKNOWLEDGEMENT_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( RMA_ACKNOWLEDGEMENT_XSL_FILE , "" ) );
    }

     public static String getQuoteAckXml2PdfXslFile()
     {
         if( System.getProperty( "cmd" ) != null )
         {
             return s_props.getProperty( QUOTE_ACKNOWLEDGEMENT_XSL_FILE_CMD );
         }
         return s_servletContext.getRealPath( s_props.getProperty ( QUOTE_ACKNOWLEDGEMENT_XSL_FILE , "" ) );
     }

     public static String getAirgoCommercialInvoiceXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( AIRGO_COMMERCIAL_INVOICE_XML2PDF_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( AIRGO_COMMERCIAL_INVOICE_XML2PDF_XSL_FILE , "" ) );
    }

    public static String getAirgoQuoteAckXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( AIRGO_QUOTE_ACKNOWLEDGEMENT_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( AIRGO_QUOTE_ACKNOWLEDGEMENT_XSL_FILE , "" ) );
    }
     public static String getAirgoPackingSlipXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( AIRGO_PACKINGSLIP_XML2PDF_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( AIRGO_PACKINGSLIP_XML2PDF_XSL_FILE , "" ) );
    }
    public static String getMailerTempDir()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( MAILER_TEMP_DIR_CMD );
        }

        return s_servletContext.getRealPath( s_props.getProperty ( MAILER_TEMP_DIR, "" ) );
    }
    
    public static String getChipTracImagesDir()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( IMAGES_DIR_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( IMAGES_DIR, "" ) );
    }


    public static String getScalarLogo()
    {
           String temp = s_props.getProperty( IMAGES_SCALARLOGO );
           if ( (temp == null) || ( temp.trim().length() == 0 ) ){
                temp = "/scalar_logo.jpg";
           }
           if( !temp.startsWith("/") )
                temp = "/" + temp;
           return temp;
    }

    public static String getCrossCanelImage()
    {
        String temp = s_props.getProperty( IMAGES_CROSS_CANCEL );
        if ( (temp == null) || ( temp.trim().length() == 0 ) ){
                temp = "/cross_cancel.gif";
           }
       if( !temp.startsWith("/") )
           temp = "/" + temp;
       return temp;
    }

    public static String getTSMCPathDirectory()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( TSMC_ADAPTOR_PCMDATA_DIR_CMD );
        }
        return s_props.getProperty ( TSMC_ADAPTOR_PCMDATA_DIR, "" ) ;
    }

    public static String getTSMCPathLink()
    {
        return s_props.getProperty ( TSMC_PCMDATA_PATH_LINK, "" );
    }
    // -- END --

    public static void main (String[] args) {
        System.out.println ("Mail host = " + getMailHost());
        System.out.println ("Mailer Enabled = " + isMailerEnabled());
        System.out.println ("Day to keep adaptor run info = " + getDaysToKeepAdaptorRunInfo());
        System.out.println ("System Administrator Email = " + getSysAdminEmail());
        System.out.println ("log file count = " + getLoggerCount() );
    }

    public static String getFinanceIntegrationType()
    {
        return s_props.getProperty( FINANCE_INTEGRATION_TYPE );
    }

    public static String getSalesIntegrationType()
    {
        return s_props.getProperty( SALES_INTEGRATION_TYPE );
    }

    public static String getSiteMapConfigFile()
    {
        return s_servletContext.getRealPath( s_props.getProperty( SITE_MAP_CONFIG_FILE ) );
    }

    //BR, March 18, 2004
    public static boolean isVendorFacingAllowedForshipping()
    {
        return Boolean.valueOf( s_props.getProperty( ALLOW_VENDOR_TO_UPDATE_SHIPPING_DETAILS ) ).booleanValue();
    }

    public static String getPmfFilePath()
    {
        return s_props.getProperty( PMF_FILE_PATH );
    }

    public static String getVendorMaskFilePath()
    {
        return s_props.getProperty( VENDOR_MASK_FILE_DIRECTORY );
    }

    public static String getRmaFilePath()
    {
        return s_props.getProperty( RMA_FILE_PATH );
    }

    public static String getForecastDocFilePath()
    {
        return s_props.getProperty( FORECAST_DOC_FILE_PATH );
    }
    public static String getGPCompanyID()
    {
        return s_props.getProperty( GP_COMPANY_ID );
    }

    public static String getConvertionExecXLStoCVSName()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( SCALAR_CHIPTRACK_ADAPTOR_CONVERTXML2CSV_EXE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( SCALAR_CHIPTRACK_ADAPTOR_CONVERTXML2CSV_EXE , "" ) );
    }

    public static String getClientNameAirgo()
    {
        String clientName = s_props.getProperty ( CLIENT_NAME_AIRGO );

        if (clientName != null){
            clientName =  clientName.trim();
        }

        return  clientName ;
    }

    public static String getWeblsResponseDirectory()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( WEBLS_RESPONSE_FILE_DIRECTORY_CMD );
        }
        return s_props.getProperty ( WEBLS_RESPONSE_FILE_DIRECTORY, "" );

    }

    public static String getEndCustomerMigrationDirectory()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( ENDCUSTOMER_MIGRATION_FILE_DIRECTORY_CMD );
        }
        return s_props.getProperty ( ENDCUSTOMER_MIGRATION_FILE_DIRECTORY, "" );

    }

    public static String getEndCustomerMigrationExcelColumnsFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( ENDCUSTOMER_MIGRATION_EXCEL_COLUMNS_FILE_CMD );
        }
        return s_props.getProperty ( ENDCUSTOMER_MIGRATION_EXCEL_COLUMNS_FILE, "" );

    }

    public static String getLicenseRequestDir()
    {

        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( LICENSE_REQUEST_DIR_CMD );
        }

        return s_props.getProperty ( LICENSE_REQUEST_DIR, "" );
    }

    public static String getPackingSlipMailerDir()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( MAILER_TEMP_DIR );
        }
        return s_props.getProperty( MAILER_TEMP_DIR, "" );
    }

    public static String getAdaptorListFile()
    {
        if (System.getProperty("cmd") != null) {
            return s_props.getProperty (ADAPTOR_LIST_CMD);
        }

        return s_servletContext.getRealPath(s_props.getProperty (ADAPTOR_LIST, ""));
    }

   public static String getPartNumbersAckXml2PdfXslFile()
   {
       if( System.getProperty( "cmd" ) != null )
       {
           return s_props.getProperty(PART_NUMBERS_XSL_FILE_CMD );
       }
       return s_servletContext.getRealPath( s_props.getProperty ( PART_NUMBERS_XSL_FILE , "" ) );
   }

    public static boolean isEndUserPartNumbersAllowed()
    {
        if(s_props.getProperty( ALLOW_ENDUSER_PARTNUMBERS ) != null ){
            return Boolean.valueOf( s_props.getProperty( ALLOW_ENDUSER_PARTNUMBERS ) ).booleanValue();
        }else{
            return false;
        }
    }

    public static String getForecastSqlQueryMappingFile() {

        if (System.getProperty("cmd") != null) {
            return s_props.getProperty (FORECAST_SQL_QUERY_MAPPING_FILE_CMD);
        }
        return s_servletContext.getRealPath(s_props.getProperty (FORECAST_SQL_QUERY_MAPPING_FILE, ""));
    }

    public static String getAssmReleaseXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( ASSMRELEASE_XML2PDF_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( ASSMRELEASE_XML2PDF_XSL_FILE , "" ) );
    }


    public static String getSortReleaseXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( SORTRELEASE_XML2PDF_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( SORTRELEASE_XML2PDF_XSL_FILE , "" ) );
    }

    public static String getFabReleaseXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( FABRELEASE_XML2PDF_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( FABRELEASE_XML2PDF_XSL_FILE , "" ) );
    }

    public static String getTestReleaseXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( TESTRELEASE_XML2PDF_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( TESTRELEASE_XML2PDF_XSL_FILE , "" ) );
    }

    public static String getScalarAdminEmail()
    {
        return s_props.getProperty( SCALAR_ADMIN_EMAIL );
    }
    public static String getSalesOrdersSheetDirectory()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( SALES_ORDERS_SHEET_DIRECTORY_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( SALES_ORDERS_SHEET_DIRECTORY , "" ) );
    }

    public static String getScalarEventListenersDefFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( SCALAR_EVENT_LISTENERS_DEF_FILE_CMD );
        }

        return s_servletContext.getRealPath( s_props.getProperty( SCALAR_EVENT_LISTENERS_DEF_FILE ) );
    }

    public static String getWipFedSheetDirectory()
    {
        if ( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( WIP_FED_SHEET_DIRECTORY_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty( WIP_FED_SHEET_DIRECTORY, "" ) );
    }

    public static String getWipFedSortSheetDirectory()
    {
        if ( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( WIP_FED_SORT_SHEET_DIRECTORY_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty( WIP_FED_SORT_SHEET_DIRECTORY, "" ) );
    }

    public static String getCostCodesSheetDirectory()
    {
        if (System.getProperty("cmd") != null)
        {
            return s_props.getProperty(COST_CODE_SHEET_DIRECTORY_CMD);
        }
        return s_servletContext.getRealPath(s_props.getProperty(COST_CODE_SHEET_DIRECTORY, ""));
    }

    public static String getCostCodePortingDirectory()
    {
        if (System.getProperty("cmd") != null)
        {
            return s_props.getProperty(COST_CODE_PORTING_FILE_PATH_CMD);
        }
        return s_servletContext.getRealPath(s_props.getProperty(COST_CODE_PORTING_FILE_PATH, ""));
    }

    public static String getPriceSetupPortingDirectory()
    {
        if (System.getProperty("cmd") != null)
        {
            return s_props.getProperty(PRICE_SETUP_PORTING_FILE_PATH_CMD);
        }
        return s_servletContext.getRealPath(s_props.getProperty(PRICE_SETUP_PORTING_FILE_PATH, ""));
    }

    public static String getWipFlushFilePath ( )
    {
        return s_props.getProperty( WIP_FLUSH__FILE_PATH );
    }

    public static String getOnDemandAdaptorStatusTimeOut ()
    {
        return s_props.getProperty( ON_DEMAND_ADAPTOR_STATUS_TIME_OUT, "0" );
    }

    public static double getInventoryTransitAssyYield()
    {
        return Double.parseDouble( s_props.getProperty(INVENTORY_TRANSIT_ASSY_YIELD) );
    }
    public static double getInventoryTransitTestYield()
    {
        return Double.parseDouble( s_props.getProperty(INVENTORY_TRANSIT_TEST_YIELD) );
    }
    public static double getInventoryTransitCSYield()
    {
        return Double.parseDouble( s_props.getProperty(INVENTORY_TRANSIT_CS_YIELD) );
    }
    public static String getDataDumpReportsFilePath ()
    {
        return s_props.getProperty( DATA_DUMP_REPORTS_FILE_PATH );
    }

     public static String getWipFlushXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( WIPFLUSH_XML2PDF_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( WIPFLUSH_XML2PDF_XSL_FILE , "" ) );
    }

    public static String getWipFlushFilePathCmd()
    {
        return s_servletContext.getRealPath( s_props.getProperty ( WIP_FLUSH__FILE_PATH , "" ) );
    }

    public static String getConvertionXLStoHTMLName()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( SCALAR_CHIPTRACK_ADAPTOR_CONVERTXLS2HTML_EXE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( SCALAR_CHIPTRACK_ADAPTOR_CONVERTXLS2HTML_EXE , "" ) );
    }

    public static String getShippingRequestXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( SHIPREQUEST_XML2PDF_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( SHIPREQUEST_XML2PDF_XSL_FILE , "" ) );
    }

    public static NotificationEmailInfo getNotificationEmailInfo()
    {
        if ( notificationEmailInfo == null )
        {
            try
            {
                notificationEmailInfo = NotificationDAO.getAllNotificationMailIdList();
            }
            catch ( Exception e ){ }
        }
        return notificationEmailInfo;
    }

    public static int getGeneratePSScheduledUptoDays ()
    {
        int noOfDays = 1;
        try
        {
            noOfDays = Integer.parseInt( s_props.getProperty( GENERATE_PS_SCHEDULED_UPTO_DAYS, "1" ) );
        } catch( NumberFormatException ignore ) {}

        return noOfDays;
    }

    public static boolean getShowFabLotNumberInPackingSlip()
    {
    	boolean showFabLotNumber = false;
        try
        {
        	showFabLotNumber = Boolean.valueOf( s_props.getProperty( SHOW_FAB_LOT_NUMBER_IN_PACKING_SLIP )).booleanValue();;
        } catch( Exception e ) {}

    	return showFabLotNumber;
    }

    public static boolean getShowPackageDimensionInPackingSlip()
    {
    	boolean showFabLotNumber = false;
        try
        {
        	showFabLotNumber = Boolean.valueOf( s_props.getProperty( SHOW_PACKAGE_DIMENSION_IN_PACKING_SLIP )).booleanValue();;
        } catch( Exception e ) {}

    	return showFabLotNumber;
    }

    public static int getPSShippedInDays ()
    {
        int noOfDays = 7;
        try
        {
            noOfDays = Integer.parseInt( s_props.getProperty( PS_SHIPPED_IN_DAYS, "7" ) );
        } catch( NumberFormatException ignore ) {}

        return noOfDays;
    }
    public static String getPackingSlipFromMailId ()
    {
        return s_props.getProperty( PACKING_SLIP_FROM_MAIL_ID );
    }

    public static String getSalesOrderFromMailId()
    {
        return s_props.getProperty( SALES_ORDER_FROM_MAIL_ID );
    }
    public static String getCreditNoteAckXml2PdfXslFile()
    {
        if( System.getProperty( "cmd" ) != null )
        {
            return s_props.getProperty( CREDIT_NOTE_ACKNOWLEDGEMENT_XSL_FILE_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( CREDIT_NOTE_ACKNOWLEDGEMENT_XSL_FILE , "" ) );
    }
    public static String getFromEmailCategory ()
    {
        return  s_props.getProperty( FROM_EMAIL_CATEGORY );
    }
    public static String getFromEmailId(String groupName)
    {
        String category = getFromEmailCategory();

        if ( Constants.FROM_EMAIL_CATEGORY_USER.equalsIgnoreCase( category ) )
        {
            return ( getCurrentUserEmail() != null && getCurrentUserEmail().trim().length() > 0 ) ? getCurrentUserEmail() : getSysAdminEmail();
        }
        else if ( Constants.FROM_EMAIL_CATEGORY_ADMIN.equalsIgnoreCase( category ) )
        {
            return getSysAdminEmail();
        }
        else //BY GROUP
        {
            if ( Constants.FROM_EMAIL_SALES_GROUP_NAME.equalsIgnoreCase( groupName ) )
            {
                return getSalesOrderFromMailId();
            }
            else if ( Constants.FROM_EMAIL_PACKINGSLIP_GROUP_NAME.equalsIgnoreCase( groupName ) )
            {
                return getPackingSlipFromMailId();
            }
            else
            {
                return getSysAdminEmail();
            }
        }
    }

    public static String getSpecFilePath()
	{
        if (System.getProperty("cmd") != null)
        {
            return s_props.getProperty( SPEC_FILE_SETUP_PATH_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty( SPEC_FILE_SETUP_PATH, "" ) );
    }

    public static String getSpecFilePathContext()
	{
		return s_props.getProperty( SPEC_FILE_SETUP_PATH );
	}
    public static String getReleaseWaferMapFileDir()
	{
        if (System.getProperty("cmd") != null)
        {
            return s_props.getProperty( RELEASE_WAFERMAP_FILE_DIR_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty( RELEASE_WAFERMAP_FILE_DIR, "" ) );
    }

    public static boolean isShowQuoteMinOrderQty() {
        return Boolean.valueOf(s_props.getProperty(QUOTE_SHOW_MIN_ORDER_QTY)).booleanValue();
    }

    public static boolean isShowQuoteRequestedPrice()
    {
        return Boolean.valueOf(s_props.getProperty( QUOTE_SHOW_REQUESTED_PRICE )).booleanValue();
    }
    public static boolean isShowQuoteCustResalePrice()
    {
        return Boolean.valueOf(s_props.getProperty( QUOTE_SHOW_CUST_RESALE_PRICE )).booleanValue();
    }
    public static boolean isShowQuoteSuggResalePrice()
    {
        return Boolean.valueOf(s_props.getProperty(  QUOTE_SHOW_SUGG_RESALE_PRICE )).booleanValue();
    }

    public static boolean isEndCustomerMandatory()
    {
        return Boolean.valueOf(s_props.getProperty(  IS_END_CUSTOMER_MANDATORY )).booleanValue();
    }
    public static boolean isEndUserMandatory()
    {
        return Boolean.valueOf(s_props.getProperty(  IS_END_USER_MANDATORY )).booleanValue();
    }
    public static boolean isDefaultZeroPriceForSampleSO()
    {
        return Boolean.valueOf(s_props.getProperty(  SAMPLES_IS_DEFAULT_ZERO_PRICE )).booleanValue();
    }
    public static boolean isQuoteTypeMandatory()
    {
        return Boolean.valueOf(s_props.getProperty(  IS_QUOTE_TYPE_MANDATORY )).booleanValue();
    }

    public static String getReleaseFileDir()
    {
        return s_props.getProperty( RELEASE_FILE_DIR_CMD );
    }

     public static String getReleaseFileWebDir()
    {
        String propertyString = s_props.getProperty( RELEASE_FILE_DIR ) ;
        if( propertyString != null && propertyString.trim().length() > 0 )
        {
            return propertyString;
        }
        else
        {
             return null;
        }
    }
    public static boolean getShowTermsLabel()
    {
       return Boolean.valueOf(s_props.getProperty(IS_SHOW_TERMS_LABEL )).booleanValue();
    }
    public static boolean isSendShipmentNotificationMail()
    {
        return Boolean.valueOf(s_props.getProperty(  SEND_PS_SHIPMENT_NOTIFICATION_MAIL )).booleanValue();
    }
    public static boolean isSendShipmentNotificationWhenPulledFromConsignmentWareHouse()
    {
        return Boolean.valueOf(s_props.getProperty(  SEND_PS_SHIPMENT_NOTIFICATION_WHEN_PULLED_FROM_CONSIGNMENT_WAREHOUSE )).booleanValue();
    }
    public static boolean getShowTermsFromDB()
    {
       return Boolean.valueOf(s_props.getProperty(IS_SHOW_TERMSFROMDB_LABEL )).booleanValue();
    }


    public static boolean isSendApprovedSalesOrderNotificationMailToCustomer()
    {
        return Boolean.valueOf( s_props.getProperty( SEND_APPROVED_SO_NOTIFICATION_MAIL_TO_CUSTOMER ) ).booleanValue();
    }

    public static boolean isSendApprovedQuotationNotificationMailToCustomer()
    {
        return Boolean.valueOf( s_props.getProperty( SEND_APPROVED_QUOTATION_NOTIFICATION_MAIL_TO_CUSTOMER ) ).booleanValue();
    }

     public static String getUOMForPackingslip()
	{
		return s_props.getProperty( PACKINGSLIP_UOM_VALUE );
	}

    public static int getPSShipDateAllowedElapsedDays()
    {
        int noOfDays = 0;
        try
        {
           noOfDays = Integer.parseInt( s_props.getProperty( PACKINGSLIP_SHIPDATE_ALLOWED_ELAPSED_DAYS, "0" ) );
        } catch( NumberFormatException ignore ) {}

        return noOfDays;
    }

    public static boolean isCIIncludePackingslip()
    {
        return Boolean.valueOf(s_props.getProperty( PACKINGSLIP_IS_INCLUDE_CI )).booleanValue();
    }

    /**
     *
     * @return returns Job Abort time in milli seconds
     */
    public static long getJobAbortTime()
    {
        String period = s_props.getProperty (JOB_ABORT_TIME_MILLIS);
        long value = 1200000; //20 min default
        try
        {
            value = Long.parseLong (period);
        }
        catch (NumberFormatException nfe)
        {
            // invalid property value, return default value
        }

        return value;
    }
    public static boolean isLoadEndCustomersForNewSales()
    {
        return Boolean.valueOf(s_props.getProperty(SALES_LOAD_END_CUSTOMERS_FOR_NEW )).booleanValue();
    }
    public static boolean isLoadEndUsersForNewSales()
    {
        return Boolean.valueOf(s_props.getProperty(SALES_LOAD_END_USERS_FOR_NEW )).booleanValue();
    }

    public static String getCummulativeYieldReportFileDir()
    {
        return s_props.getProperty( CUMMULATIVE_YIELD_REPORT_FILE_DIR_CMD );
    }
    public static boolean isLoadQuotationQuestionnaire()
    {
        return Boolean.valueOf(s_props.getProperty(SALES_LOAD_QUOTATION_QUESTIONNAIRE )).booleanValue();
    }


    public static String getCummulativeYieldReportFileWebDir()
    {
        String propertyString = s_props.getProperty( CUMMULATIVE_YIELD_REPORT_FILE_DIR ) ;
        if( propertyString != null && propertyString.trim().length() > 0 )
        {
            return propertyString;
        }
        else
        {
             return null;
        }
    }

    public static String getQuestionnaireFilePath()
	{
        if (System.getProperty("cmd") != null)
        {
            return s_props.getProperty( QUESTIONNAIRE_FILE_SETUP_PATH_CMD );
        }
        return s_servletContext.getRealPath( s_props.getProperty( QUESTIONNAIRE_FILE_SETUP_PATH, "" ) );
    }

    public static String getQuestionnaireFilePathContext()
	{
		return s_props.getProperty( QUESTIONNAIRE_FILE_SETUP_PATH );
	}
     public static boolean isSendQuotationInternalCommentsMail()
    {
        return Boolean.valueOf(s_props.getProperty(QUOTATION_SEND_INTERNAL_COMMENTS_MAIL )).booleanValue();
    }
    public static String getCrossNotApprovedImage()
    {
        String temp = s_props.getProperty( IMAGES_CROSS_NOTAPPROVED );
        if ( (temp == null) || ( temp.trim().length() == 0 ) ){
                temp = "//not_approved_icon.gif";
           }
       if( !temp.startsWith("/") )
           temp = "/" + temp;
       return temp;
    }

    public static int getnoOfDecmalsInAmount()
    {
        int noOfDecmals = 2;
        try
        {
           noOfDecmals = Integer.parseInt( s_props.getProperty( NO_OF_DECIMALSIN_AMOUNT_FORMAT, "3" ) );
        } catch( NumberFormatException ignore ) {}

        return noOfDecmals;
    }

    /**
     * Returns the decimal pattern for the specified no of Decimals in propreties file.
     * @return the decimal pattern.<br>
     * if no. of decimals &lt;= 0 Then ''<br>
     * if no. of decimals = 1 Then '.0'<br>
     * if no. of decimals = 2 Then '.00'<br>
     * if no. of decimals = 3 Then '.000' etc.<br>
     */
    public static String getDecmalsInAmountPattern(){
        int noOfDecmals = getnoOfDecmalsInAmount();
        String pattern = ".";
        for(int i=0; i < noOfDecmals; i++) {
            pattern += "0";
        }

        return pattern.length()==1?"":pattern;
    }
    public static int getExpiryNoOfDays()
   {
       int NoOfDays = 7;
       try{
           NoOfDays = Integer.parseInt ( s_props.getProperty( EXPIRY_NO_OF_DAYS_FROM_CURRENT_DATE, "7" ) );
       } catch ( NumberFormatException ignore ) {}
       return NoOfDays;
   }
   public static String getExpiryUsersReportDirectory()
   {
       String propertyString = ( System.getProperty( "cmd" ) != null ) ? s_props.getProperty(EXPIRY_USERS_REPORT_FILE_PATH_CMD  )  : s_props.getProperty( EXPIRY_USERS_REPORT_FILE_PATH );
       if( propertyString != null && propertyString.trim().length() > 0 )
       {
           return ( System.getProperty( "cmd" ) != null ) ? propertyString : s_servletContext.getRealPath( propertyString );
       }
       else
       {
            return null;
       }
   }
    public static boolean isDupMktgPartNumberAllowed()
    {
        return Boolean.valueOf(s_props.getProperty(IS_DUPLICATE_MKTG_PART_NUMBERS_ALLOWED)).booleanValue();
    }
    public static String getSalesBacklogPortingFileDir()
    {
        String propertyString = ( System.getProperty( "cmd" ) != null ) ? s_props.getProperty( SALES_PORTING_FILE_DIR_CMD )  : s_props.getProperty( SALES_PORTING_FILE_DIR );
        if( propertyString != null && propertyString.trim().length() > 0 )
        {
            return ( System.getProperty( "cmd" ) != null ) ? propertyString : s_servletContext.getRealPath( propertyString );
        }
        else
        {
             return null;
        }
    }

    public static String getForcastPortingFileDir()
    {
        String propertyString = ( System.getProperty( "cmd" ) != null ) ? s_props.getProperty( FORECAST_PORTING_FILE_DIR_CMD )  : s_props.getProperty( FORECAST_PORTING_FILE_DIR );
        if( propertyString != null && propertyString.trim().length() > 0 )
        {
            return ( System.getProperty( "cmd" ) != null ) ? propertyString : s_servletContext.getRealPath( propertyString );
        }
        else
        {
             return null;
        }
    }
    public static String getBuildForcastPortingFileDir()
    {
        String propertyString = ( System.getProperty( "cmd" ) != null ) ? s_props.getProperty( BUILD_FORECAST_PORTING_FILE_DIR_CMD )  : s_props.getProperty( BUILD_FORECAST_PORTING_FILE_DIR );
        if( propertyString != null && propertyString.trim().length() > 0 )
        {
            return ( System.getProperty( "cmd" ) != null ) ? propertyString : s_servletContext.getRealPath( propertyString );
        }
        else
        {
             return null;
        }
    }
    public static String getPoFileDir()
    {
        String propertyString = ( System.getProperty( "cmd" ) != null ) ? s_props.getProperty( PO_PORTING_FILE_DIR_CMD )  : s_props.getProperty( PO_PORTING_FILE_DIR );
        if( propertyString != null && propertyString.trim().length() > 0 )
        {
            return ( System.getProperty( "cmd" ) != null ) ? propertyString : s_servletContext.getRealPath( propertyString );
        }
        else
        {
             return null;
        }
    }
    public static String getCustomerFileDir()
    {
        String propertyString = ( System.getProperty( "cmd" ) != null ) ? s_props.getProperty( CUSTOMER_PORTING_FILE_DIR+".cmd" )  : s_props.getProperty( CUSTOMER_PORTING_FILE_DIR );
        if( propertyString != null && propertyString.trim().length() > 0 )
        {
            return ( System.getProperty( "cmd" ) != null ) ? propertyString : s_servletContext.getRealPath( propertyString );
        }
        else
        {
             return null;
        }
    }
    public static String getProductPortingFileDir()
    {
        String propertyString = ( System.getProperty( "cmd" ) != null ) ? s_props.getProperty( PRODUCT_PORTING_FILE_DIR+".cmd" )  : s_props.getProperty( PRODUCT_PORTING_FILE_DIR );
        if( propertyString != null && propertyString.trim().length() > 0 )
        {
            return ( System.getProperty( "cmd" ) != null ) ? propertyString : s_servletContext.getRealPath( propertyString );
        }
        else
        {
             return null;
        }
    }
    public static String getInvoicePortingFileDir()
    {
        String propertyString = ( System.getProperty( "cmd" ) != null ) ? s_props.getProperty( FAB_INVOICE_PORTING_FILE_DIR+".cmd" )  : s_props.getProperty( FAB_INVOICE_PORTING_FILE_DIR );
        if( propertyString != null && propertyString.trim().length() > 0 )
        {
            return ( System.getProperty( "cmd" ) != null ) ? propertyString : s_servletContext.getRealPath( propertyString );
        }
        else
        {
             return null;
        }
    }

    public static boolean isReleaseShowMarkingLines()
    {
        return Boolean.valueOf(s_props.getProperty( RELEASE_SHOW_MARKING_LINES )).booleanValue();

    }
    public static boolean isGenerateReleaseLotNumber()
    {
        return Boolean.valueOf(s_props.getProperty( GENERATE_ASSY_RELEASE_NUMBER )).booleanValue();

    }
    
    public static boolean isShowUpdateViewCostByLocation()
    {
        return Boolean.valueOf(s_props.getProperty( SHOW_UPDATE_VIEW_COST_BY_LOCATION )).booleanValue();
    }
    
    public static boolean isBomPullingByWaferId()
    {
        return Boolean.valueOf(db_props.getProperty( IS_BOM_INVENOTORY_PULLING_BY_WAFER_ID )).booleanValue();
    }
    
    public static boolean isReleaseShippedLotGroupByWaferId()
    {
        return Boolean.valueOf(db_props.getProperty( IS_SHOW_RELEASE_SHIPLOT_GROUP_BY_WAFER_ID )).booleanValue();
    }

    public static String getReleaseMailSubjectFormat()
    {
        return db_props.getProperty( "scalar.chiptrack.operations.release.mailSubjectFormat", "Format1" );
    }
    
    public static boolean getReleaseRestrictVendorLocation()
    {
        return Boolean.valueOf(db_props.getProperty( "scalar.chiptrack.operations.release.restrictvendor", "false" )).booleanValue();
    }
    public static boolean isSaveEndCustomerandEndUser()
    {
        return Boolean.valueOf(db_props.getProperty(IS_SAVE_END_CUSTOMER_END_USER)).booleanValue();
    }
    public static boolean isCalculateCostByCummulative()
    {
        return Boolean.valueOf(db_props.getProperty(IS_CALCULATE_COST_BY_CUMMULATIVE)).booleanValue();
    }
    public static boolean showDieBankLotNo()
    {
        return Boolean.valueOf(db_props.getProperty(SHOW_RELEASE_DIEBANKLOT_NO_LABEL)).booleanValue();
    }
    public static boolean showScreenPrintOrder()
    {
        return Boolean.valueOf(db_props.getProperty(SHOW_RELEASE_SCREENPRINT_ORDER_LABEL)).booleanValue();
    }
    public static boolean showBackGrindOrder()
    {
        return Boolean.valueOf(db_props.getProperty(SHOW_RELEASE_BACKGRIND_ORDER_LABEL)).booleanValue();
    }

    public static boolean generateTestRelease()
    {
        return Boolean.valueOf(db_props.getProperty(GENERATE_TEST_RELEASE, "ture") ).booleanValue();
    }

    public static String getDefaultTestReleaseFileFormat()
    {
        return db_props.getProperty( DEFAULT_TEST_RELEASE_FILE_FORMAT, "PDF" );
    }
    public static String getDefaultAssmReleaseFileFormat()
    {
        return db_props.getProperty( DEFAULT_ASSM_RELEASE_FILE_FORMAT, "PDF" );
    }

    public static String generateAssyReleaseShipLotNo()
    {
        return db_props.getProperty("scalar.chiptrack.release.assm.generateReleaseLotNo", "ShipLotNo") ;
    }
    public static boolean saveTestRelease()
    {
        return Boolean.valueOf(db_props.getProperty("scalar.chiptrack.release.test.saveTestRelease", "false") ).booleanValue();
    }

    public static boolean uploadAssyReleaseToFTP()
    {
        return Boolean.valueOf(db_props.getProperty("scalar.chiptrack.release.assm.uploadToFTP", "false") ).booleanValue();
    }
    public static boolean uploadTestReleaseToFTP()
    {
        return Boolean.valueOf(db_props.getProperty("scalar.chiptrack.release.test.uploadToFTP", "false") ).booleanValue();
    }
    public static boolean attachWaferMap()
    {
        return Boolean.valueOf(db_props.getProperty("scalar.chiptrack.release.assm.attachWaferMap", "false") ).booleanValue();
    }
    
    public static boolean isVendorGeneratePackingSlip()
    {
        return Boolean.valueOf(db_props.getProperty("scalar.chiptrack.operations.packingslip.vendorGeneratePackingSlip", "false") ).booleanValue();
    }

    public static String getAssemblyReleaseByPartNumber()
    {
        return db_props.getProperty("scalar.chiptrack.operations.assemblyrelease.byFGorAssemblyPart", "FG");
    }
    public static String getXLSWorkBookFormat()
    {
        return db_props.getProperty("scalar.chiptrack.excelworkBookFormat", "xls");
    }
    public static boolean calculateBuildQtyByLot()
    {
         return Boolean.valueOf(db_props.getProperty("scalar.chiptrack.release.assm.calculateBuildQtyByLot", "false") ).booleanValue();
    }
    public static boolean isMultipleBillingAddressesAllowed() {
        return Boolean.valueOf(s_props.getProperty("scalar.chiptrack.customer.allowMultipleBillingAddresses", "false"));
    }
    public static String getBarcodeConfigurationFile(){
        if( System.getProperty( "cmd" ) != null ){
            return s_props.getProperty( BARCODE_CONFIG_FILE+".cmd" );
        }
        return s_servletContext.getRealPath( s_props.getProperty ( BARCODE_CONFIG_FILE , "" ) );
    }

	public static int getIntProperty(String key) {
		String value = s_props.getProperty(key);
		if(value == null) {
			value = db_props.getProperty(key);
		}
		return new Integer(value);
	}

	public static String getProperty(String key) {
		String value = s_props.getProperty(key);
		if(value == null) {
			value = db_props.getProperty(key);
        }
		return value;
	}

	public static boolean getBooleanProperty(String key) {
		String value = getProperty(key);
		if(value == null){
			return false;
		} else if("true".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value)) {
			return true;
		} else if("false".equalsIgnoreCase(value) || "no".equalsIgnoreCase(value)) {
			return false;
		}

		throw new RuntimeException("Invalid Boolean vlaue '"+value+"' for the key '" + key + "'");
	}
	
    public static String getFabFileDir()
    {
        String propertyString = ( System.getProperty( "cmd" ) != null ) ? s_props.getProperty( FAB_PORTING_FILE_DIR_CMD )  : s_props.getProperty( FAB_PORTING_FILE_DIR );
        if( propertyString != null && propertyString.trim().length() > 0 )
        {
            return ( System.getProperty( "cmd" ) != null ) ? propertyString : s_servletContext.getRealPath( propertyString );
        }
        else
        {
             return null;
        }
    }

}